package cn.com.open.itembank.mapper;

import cn.com.open.itembank.dto.ItemBankCount;
import cn.com.open.itembank.entity.CourseItemBank;
import cn.com.open.itembank.sqlprovider.AppSqlProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;

import java.util.List;

@Mapper
public interface AppMapper {
    /**
     * 获取appKey列表.
     *
     * @return the list
     */
    @Select("SELECT distinct AppID FROM CourseItemBank WHERE status=0 ORDER BY AppID")
    List<String> getAppList();

    /**
     * 获取课程题库信息，根据appKey和orgid
     *
     * @param appKey AppID
     * @param orgId  机构标识
     * @return the list
     */
    @Select("SELECT * FROM CourseItemBank WHERE AppID=#{appKey} AND CreateOrgID=#{orgId} AND Status=0")
    List<CourseItemBank> getItembankListByAppKeyAndOrgId(@Param("appKey") String appKey, @Param("orgId") String orgId);

    /**
     * 根据appKey获取对应题库试题数量信息
     *
     * @param appKey APPID
     * @return the list
     */
    @SelectProvider(type = AppSqlProvider.class, method = "getItemBankQuestionCountByAppKey")
    List<ItemBankCount> getItemBankQuestionCountByAppKey(@Param("appKey") String appKey);
}
